<template>
  <div class="context-menu" :style="style" @mousedown.stop @mousewheel.stop>
    <slot></slot>
  </div>
</template>

<script>
export default {
  props: {
    pos: Object,
  },

  computed: {
    style() {
      return {
        left: `${this.pos.x}px`,
        top: `${this.pos.y}px`,
      };
    },
  },
};
</script>

<style>
.context-menu {
  background-color: var(--vscode-menu-background);
  color: var(--vscode-menu-foreground);
  border: 1px solid var(--vscode-menu-border);
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
  position: absolute;
  user-select: none;
  padding: 6.5px 0px;
  max-height: 200px;
  overflow: scroll;
}

.context-menu .separator {
  margin-bottom: 0.2em;
  margin-left: 0.8em !important;
  margin-right: 0.8em !important;
  padding: 0.2em 0 0 0;
  width: 100%;
  height: 0px !important;
  opacity: 0.4;
  border-bottom: 1px solid var(--vscode-menu-separatorBackground);
}

.context-menu input[type='text'] {
  height: 1.8em;
  margin: 0px 26px;
  background-color: var(--vscode-input-background);
  color: var(--vscode-input-foreground);
  border: none;
}

.context-menu input[type='text']:focus {
  height: 1.8em;
  outline: none;
}

.context-menu ul {
  padding: 0;
  margin: 0;
  list-style-type: none;
  border: thin solid transparent;
}

.context-menu ul li {
  margin: 0;
  padding: 0;
  height: 1.8em;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
}

.context-menu .menu-item {
  height: 1.8em;
  padding: 0px 26px;
  cursor: pointer;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
}

.context-menu .menu-item:hover {
  background-color: var(--vscode-menu-selectionBackground);
  color: var(--vscode-menu-selectionForeground);
}

.context-menu .codicon {
  margin-right: 10px;
}
</style>
